import request from '../utils/request';

/**
 * 查找所有角色
 * @param data
 */
export const getRoleList = (roleList:Object) => {
    return request({
        url: '/role/getRoleList',
        method: 'get',
    }).then(res => {
        roleList.data = res.data
    })
}

/**
 * 分页查询
 */
export const queryRolePage = (pageNo:number,pageSize:number,tableInfo:Object) => {
    return request({
        url: `/role/queryRolePage?pageNo=${pageNo}&pageSize=${pageSize}`,
        method: 'get'
    }).then(res =>{
        tableInfo.total = res.data.total
        tableInfo.records = res.data.records
    })
}


/**
 * 保存用户
 * @param role
 */
export const saveRole = (role:Object) => {
    return request({
        url: '/role/saveRole',
        method: 'post',
        data: role
    })
}

/**
 * 删除用户
 */
export const removeRole = (id: number) => {
    return request({
        url: `/role/remove?id=${id}`,
        method: 'post'
    })
}

/**
 * 获取权限的菜单-排除不全的父节点
 * @param id
 */
export const getRoleMenu = (id: number) => {
    return request({
        url: `role/getRoleMenu?id=${id}`,
        method: 'get'
    })
}
